<?php
# 01 链接数据库
$db = mysqli_connect("127.0.0.1","root","","mogujie");

# 02 插入数据
# 加载JSON数据
$jsonData = file_get_contents("list12.json");
# 把JSON数据转换PHP数组
$data = json_decode($jsonData,true);
    
# 通过for循环遍历数组
 
for($i = 0;$i<count($data);$i++)
{
  $imgSrc = $data[$i]["imgSrc"];
  $title = $data[$i]["title"];
  $nowPrice = $data[$i]["nowPrice"];
$delPrice = $data[$i]["delPrice"];
  $num = $data[$i]["num"];

 $sql = "INSERT INTO `list12` (`imgSrc`, `title`, `nowPrice`, `delPrice`, `num`, `id`) 
         VALUES ('$imgSrc', '$title', '$nowPrice', '$delPrice', '$num', null)";
$res=mysqli_query($db, $sql);
echo $res;
}
?>